package wan.moneybook;

import java.util.TreeMap;

import javax.servlet.ServletContext;

import wan.moneybook.dao.CardDao;
import wan.moneybook.dao.CategoryDao;

public class InitMap {

	public InitMap(ServletContext servletContext) {
		setCategory(servletContext);
		setCard(servletContext);
	}

	@SuppressWarnings("unchecked")
	public void setCategory(ServletContext servletContext) {
		CategoryDao dao = new CategoryDao();
		TreeMap<Integer,String>[] map = new TreeMap[3];
		map[0] = dao.getAllCategory(1000);
		map[1] = dao.getAllCategory(2000);
		map[2] = dao.getAllCategory(3000);
		servletContext.setAttribute("category", map);
	}

	public void setCard(ServletContext servletContext) {
		TreeMap<Integer,String> map = new CardDao().getAllCard();
		servletContext.setAttribute("card", map);
	}

}
